package com.yanqu.road.server.logic.recharge;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.recharge.RechargeOrder;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.guagifts.GuaGiftsModule;
import com.yanqu.road.server.gameplayer.module.activity.qixi.QixiModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.utils.property.PropertyHelper;

/**
 * 七夕
 */
public class QixiRecharge extends BaseRecharge {

    public QixiRecharge(GamePlayer player, MallInfo mallInfo, ActivityInfo activityInfo) {
        super(player, mallInfo, activityInfo);
    }

    @Override
    protected boolean isRepeatedBuy(String orderNo) {
        if (activityInfo.getType() == eActivityType.QiXiActivity.getValue()){
            return !player.getModule(QixiModule.class).canChargeSucceed(mallInfo.getMallId());
        } else if (activityInfo.getType() == eActivityType.GuaGiftsActivity.getValue()){
            return !player.getModule(GuaGiftsModule.class).canChargeSucceed(mallInfo.getMallId());
        }

        return true;
    }

    @Override
    protected void repeatedBuyLogic() {

    }

    @Override
    protected String addMall(String orderNo, RechargeOrder rechargeOrder) {
        if(null == mallInfo){
            logger.error("qixi recharge mallInfo is null,orderNo:{}", orderNo);
            return "";
        }
        player.getModule(CurrencyModule.class).addCurrency(PropertyHelper.parseStringToProperty(mallInfo.getReward()),
                eLogMoneyType.Recharge, eLogMoneyType.QixiActivityRmbMallBuy);
        return mallInfo.getReward();
    }

}
